using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;

namespace Rifts.Controls
{
	public class GroupPanel : ContentControl
	{
		static GroupPanel()
		{
			DefaultStyleKeyProperty.OverrideMetadata(typeof(GroupPanel), new FrameworkPropertyMetadata(typeof(GroupPanel)));
		}

		public static readonly DependencyProperty HeaderProperty = DependencyProperty.Register("Header", typeof(string), typeof(GroupPanel), new PropertyMetadata("", OnHeaderChanged));

		private static void OnHeaderChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
		{
			var control = o as GroupPanel;
			if (control != null)
				control.OnHeaderChanged((string)e.OldValue, (string)e.NewValue);
		}


		protected virtual void OnHeaderChanged(string oldValue, string newValue)
		{

		}

		public string Header
		{
			get { return (string)GetValue(HeaderProperty); }
			set { SetValue(HeaderProperty, value); }
		}



		#region HeaderFontSize
		public static readonly DependencyProperty HeaderFontSizeProperty =
				DependencyProperty.RegisterAttached("HeaderFontSize", typeof(double), typeof(GroupPanel),
					new FrameworkPropertyMetadata(Double.NaN, FrameworkPropertyMetadataOptions.AffectsRender | FrameworkPropertyMetadataOptions.Inherits, OnHeaderFontSizeChanged));


		private static void OnHeaderFontSizeChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
		{
			var var = o as GroupPanel;
			if (var != null)
				var.OnHeaderFontSizeChanged((double)e.OldValue, (double)e.NewValue);
		}

		protected virtual void OnHeaderFontSizeChanged(double oldValue, double newValue)
		{
		}

		public double HeaderFontSize
		{
			get { return (double)GetValue(HeaderFontSizeProperty); }
			set { SetValue(HeaderFontSizeProperty, value); }
		}

		public static void SetHeaderFontSize(UIElement element, double value)
		{
			element.SetValue(HeaderFontSizeProperty, value);
		}

		public static double GetHeaderFontSize(UIElement element)
		{
			return (double)element.GetValue(HeaderFontSizeProperty);
		}
		#endregion
	}
}
